<script type="text/javascript">

var trumpCard = new Array();
var playerOneCard = new Array();
var playerTwoCard = new Array();
var deckCards = new Array();
var cardList = new Array();
var play = new Array();
var play_two = new Array();
var cardValuePone = new Array();
var cardValuePtwo = new Array();
var isPlayerOneAttacker;
var time;
var errMsg;
var isEndAttack = false;
var collectCards;



	$.ajax({	            
	 	url: base + 'index.php/durak/cards_list_results',
	    data: "",
	    dataType: 'json',
	    success: function(data)
		{
		    deckCards = data;

			for(var x = 0; x < 36; x++)
			{
	    		if(x == 0)
	    		{
	    			 trumpCard.push(deckCards.pop());  
		    			 $('#trumpContainer')[0].innerHTML += 
		    			'<img class="trump" hidden="hidden" src="'+ img_base + trumpCard[0]['card_image'] + '"/>' ; 
	    		}
				else if(x > 0 && x < 7)
				{
					playerOneCard.push(deckCards.pop());
						$('#playerOneCardsContainer')[0].innerHTML += 
						'<img  class="img_playerOneCards" hidden="hidden" onclick=Set_PlayerOne('+ (x - 1) +') src="'+ img_base + playerOneCard[x - 1]['card_image'] + '"/>' ; 						
	    		}
	    		else if(x > 6 && x < 13)
	    		{
					playerTwoCard.push(deckCards.pop()); 
						$('#playerTwoCardsContainer')[0].innerHTML += 
						'<img  hidden="hidden" onclick=Set_PlayerTwo('+ (x - 7) +') class="img_playerTwoCards" src="'+ img_base + playerTwoCard[x - 7]['card_image'] + '"/>';			
	    		}
	    		else 
	    		{
	    			cardList.push(deckCards.pop());
		    			 $('#deckContainer')[0].innerHTML += 
		    			'<img class="imgDeck" style="position:absolute; margin:'+ (x * -1) +'px 0px 0px '+ x +'px;"  src="'+ img_base + 'Red_Back.png'	  + '"/>';	       				
	    		}
			} // end of for loop
        }
        }); // end of ajax function

	function Generate_All_Cards(is_playerOne)
	{
		$('#option')[0].hidden = "hidden";

		if($('.trump').length > 0)
		{
			$('.trump')[0].hidden = null;
			$('#trumpTitle')[0].innerHTML = "Trump Card:<br/>" + 
			trumpCard[0]['card_suite'];  
		}
		
		if(is_playerOne)
		{	
			isPlayerOneAttacker = true;
			
			$('#ptitle')[0].innerHTML = "Player One:";
	 		$('#atitle')[0].innerHTML = "Attacker";
	 		$('#ptitle1')[0].innerHTML = "Player Two:";
	 		$('#atitle1')[0].innerHTML = "Defender";  

		 	for(var x = 0; x < playerOneCard.length || x < playerTwoCard.length; x++)
		 	{
		 		 if(x < playerOneCard.length) 
		 		 {
		 		 	$('.img_playerOneCards')[x].hidden = null;
		 		 }
		 		 if(x < playerTwoCard.length) 
		 		 {
		 		 	$('.img_playerTwoCards')[x].hidden = null;
		 		 }
		 	}
	 	}
	 	else
	 	{	 			
	 		 isPlayerOneAttacker = false;

 			 $('#ptitle')[0].innerHTML = "Player One:";
	 		 $('#atitle')[0].innerHTML = "Defender";		 
	 		 $('#ptitle1')[0].innerHTML = "Player Two:";
	 		 $('#atitle1')[0].innerHTML = "Attacker"; 

	 		for(var x = 0; x < playerTwoCard.length || x < playerOneCard.length; x++)
		 	{ 	
		 		 if(x < playerOneCard.length) 
		 		 {
		 		 	$('.img_playerOneCards')[x].hidden = null;
		 		 }
		 		 if(x < playerTwoCard.length) 
		 		 {
		 		 	$('.img_playerTwoCards')[x].hidden = null;
		 		 }
		 	}
	 	}
	}

	function Set_PlayerOne(id)
	{
		if(isPlayerOneAttacker)
		{
			if(play.length == play_two.length || collectCards)
			{	
				if(isAttackAllowed(play_two, playerTwoCard, play))
				{	
					var pass = false;
					var pOneAttackerCardValue = playerOneCard[id]['card_value'];

						if(play.length == 0)
						{
							pass = true;
						}
						else if(play.length > 0 && !isFaceinPlay(pOneAttackerCardValue))
						{
							$('#note1')[0].innerHTML = "There are no "+ 
							playerOneCard[id]['card_face'] + "s in play. You can't play this card.";
							Set_ErrorMessage($('#note1'));
						}
						else if(isFaceinPlay(pOneAttackerCardValue))
						{				
							pass = true;
						}
						else
						{
							$('#note1')[0].innerHTML = "There are no "+ 
							playerOneCard[id]['card_face'] + "s in play. You can't play this card.";
							Set_ErrorMessage($('#note1'));
						}			

							if(pass)
							{
								play.push(playerOneCard[id]);
								$('.img_playOneDeck')[play.length - 1].src = img_base + playerOneCard[id]['card_image']; 
								cardValuePone.push(playerOneCard[id]);
								playerOneCard[id] = null;

								$('.img_playerOneCards')[id].hidden = "hidden";
								
								if(collectCards)
								{			
									$('#end')[0].innerHTML = "Here! You can have this card too while collecting cards!";
									$('#endAtck')[0].hidden = null;
									$('#accptCards')[0].hidden = "hidden";
								}
								else
								{							
									$('#endAtck')[0].hidden = "hidden";
									$('#accptCards')[0].hidden = null;
								}
								isGameOver(playerOneCard, playerTwoCard);
							}
								
				}
			}  
			else
			{
					$('#turn')[0].innerHTML = "Oops! just wait for your turn.";
					Set_ErrorMessage($('#turn'));	
					$('#endAtck')[0].hidden = "hidden";
			}					
		}
		else
		{
			if(play.length == play_two.length - 1  && !collectCards) 	 	
			{
				var pass = false;
				var pTwoCardSuite = cardValuePtwo[cardValuePtwo.length - 1]['card_suite']; 
				var trumpCardSuite = trumpCard[0]['card_suite'];	
				var pOneCardSuite = playerOneCard[id]['card_suite'];			
				var pOneCardValue = Number(playerOneCard[id]['card_value']);
				var pTwoCardValue = Number(cardValuePtwo[cardValuePtwo.length - 1]['card_value']);
			
					if(trumpCardSuite == pTwoCardSuite)
					{
						if(trumpCardSuite == pOneCardSuite && pOneCardValue > pTwoCardValue)
						{
							pass = true;
						}
						else
						{
							$('#note1')[0].innerHTML = "You can't defend this card";
							Set_ErrorMessage($('#note1'));
						}
					}	
					else 
					{
						if(((pOneCardSuite == pTwoCardSuite) && pOneCardValue > pTwoCardValue) || 
							trumpCardSuite == pOneCardSuite) 
						{
							pass = true;
						}
						else
						{
							$('#note1')[0].innerHTML = "You can't defend this card";
							Set_ErrorMessage($('#note1'));
						}
					}

				if(pass)
				{
					play.push(playerOneCard[id]);
					$('.img_playOneDeck')[play.length - 1].src = img_base + playerOneCard[id]['card_image'];
					cardValuePone.push(playerOneCard[id]);
					playerOneCard[id] = null;
					$('.img_playerOneCards')[id].hidden = "hidden";

					$('#accptCards-p2')[0].hidden = "hidden";										
					$('#endAtck-p2')[0].hidden = null;


					isGameOver(playerOneCard, playerTwoCard);
				}

					
			}
			else
			{					
					if(collectCards)
					{
						$('#turn')[0].innerHTML = "";
					}
					else
					{
						$('#turn')[0].innerHTML = "Oops! just wait for your turn.";
						Set_ErrorMessage($('#turn'));
					}
			}
		}			
	}

	function Set_PlayerTwo(idx)
	{	 
		if(isPlayerOneAttacker)
		{	
			if(play_two.length == play.length - 1 && !collectCards) 
			{
				var pass = false;		
				var trumpCardSuite 	= trumpCard[0]['card_suite'];
				var pOneCardSuite 	= cardValuePone[cardValuePone.length - 1]['card_suite'];
				var pTwoCardSuite 	= playerTwoCard[idx]['card_suite'];			
				var pOneCardValue 	= Number(cardValuePone[cardValuePone.length - 1]['card_value']);
				var pTwoCardValue 	= Number(playerTwoCard[idx]['card_value']);

				if(trumpCardSuite == pOneCardSuite)
				{
					if(trumpCardSuite == pTwoCardSuite && pTwoCardValue > pOneCardValue)
					{
						pass = true;
					}
					else
					{
						$('#note')[0].innerHTML = "You can't defend this card";
						Set_ErrorMessage($('#note'));
					}
				}
				else 
				{				
					if((pTwoCardSuite == pOneCardSuite && pTwoCardValue > pOneCardValue) ||
					 	pTwoCardSuite == trumpCardSuite)
					{
							pass = true;
					}
					else
					{
						$('#note')[0].innerHTML = "You can't defend this card";
						Set_ErrorMessage($('#note'));
					}
				}
	
				if(pass)
				{
					play_two.push(playerTwoCard[idx]);
					$('.img_playDeckTwo')[play_two.length - 1].src = img_base + playerTwoCard[idx]['card_image'];
					cardValuePtwo.push(playerTwoCard[idx]);
					playerTwoCard[idx] = null;
					
					$('.img_playerTwoCards')[idx].hidden = "hidden";	

					$('#endAtck')[0].hidden = null;
					$('#accptCards')[0].hidden = "hidden";

					isGameOver(playerOneCard, playerTwoCard);

				}
				
			}
			else
			{	
					if(collectCards)
					{
						$('#note')[0].innerHTML = "";
					}
					else
					{
					$('#note')[0].innerHTML = "Oops! just wait for your turn.";
					Set_ErrorMessage($('#note'));
					}
			}
		}
		else
		{
			if(play_two.length == play.length || collectCards)
			{	
				if(isAttackAllowed(play, playerOneCard, play_two))
				{	
					var pass = false;
					var pTwoCardValue = Number(playerTwoCard[idx]['card_value']);
					if(play_two.length == 0)
					{
						pass = true;
					}
					else if(play_two.length > 0 && !isFaceinPlay(pTwoCardValue))
					{
						$('#note')[0].innerHTML = "There are no "+ playerTwoCard[idx]['card_face'] + "s in play. You can't play this card.";
						Set_ErrorMessage($('#note'));
					}
					else if(isFaceinPlay(pTwoCardValue))
					{				
						pass = true;
					}
					else
					{
						$('#note')[0].innerHTML = "There are no "+ playerTwoCard[idx]['card_face'] + "s in play. You can't play this card.";
						Set_ErrorMessage($('#note'));
					}

					if(pass)
					{
						play_two.push(playerTwoCard[idx]);
						$('.img_playDeckTwo')[play_two.length - 1].src = img_base + playerTwoCard[idx]['card_image'];
						cardValuePtwo.push(playerTwoCard[idx]);
						playerTwoCard[idx] = null;
						$('.img_playerTwoCards')[idx].hidden = "hidden";
													
						
						if(collectCards)
						{
							$('#end-p2')[0].innerHTML = "Here! You can have this card too while collecting cards!";
							$('#endAtck-p2')[0].hidden = null;
							$('#accptCards-p2')[0].hidden = "hidden";
						}	
						else
						{											
							$('#endAtck-p2')[0].hidden = "hidden";
							$('#accptCards-p2')[0].hidden = null;
						}	

						isGameOver(playerOneCard, playerTwoCard);
					}
					
				}
			}
			else
			{
					$('#note')[0].innerHTML = "Oops! just wait for your turn.";
					Set_ErrorMessage($('#note'));	
					$('#endAtck-p2')[0].hidden = "hidden";
			}
		}	
	}	

	function isAttackAllowed(play, playCard, play1)
	{
		if(collectCards)
		{
			return  play1.length <= (playCard.length - play.length || play1.length <= 6);
		} 
		else
		{

			return (playCard.length - play.length) != 0;
		}
	}

	function ClearGames()
	{

	  $('#wins')[0].innerHTML = "Play Again!";
	  $('#option')[0].hidden = null;
	  loadFn();
	  for(var x = 0; x < play_two.length; x++)
	  {
		 $('.img_playDeckTwo')[x].hidden = "hidden";			
	  }
	   for(var x = 0; x < play.length; x++)
	  {
		 $('.img_playOneDeck')[x].hidden = "hidden";			
	  }

		$('#status2')[0].hidden = "hidden";
		$('#statBtn')[0].hidden = "hidden";
		$('#ptitle')[0].innerHTML = "";
		$('#atitle')[0].innerHTML = "";
		$('#turn')[0].innerHTML = "";
		$('#note')[0].innerHTML = "";
		$('#note1')[0].innerHTML = "";
		$('#end')[0].innerHTML = "";
		$('#end-p2')[0].innerHTML = "";
		$('#trumpTitle')[0].innerHTML = "";
	}

	function isGameOver(player1, player2)
	{
		if(cardList.length == 0 && $('.trump').length <= 0)
		{
			var gameover = true;
				
				for(var x = 0; x < player1.length; x++)
				{
					if(player1[x] != null)
					{
					gameover = false;	
					break;			
					}
				}	

			if(gameover)
			{		
				  for(var x = 0; x < player2.length; x++)
				  {
					 $('.img_playerTwoCards')[x].hidden = "hidden";			
				  }
				  ClearGames();		  
			}
			else
			{

				gameover = true;
				for(var y =0; y < player2.length; y++)
				{
				 	if(player2[y] != null)
					{
						gameover = false;	
					break;
					}			
				}

					if(gameover)
					{
				 		for(var x = 0; x < player1.length; x++)
				  		{
					 	$('.img_playerOneCards')[x].hidden = "hidden";			
				  		}	
				  	  	ClearGames();
					}
			}
		}
	}

	function isFaceinPlay(face_value)
	{ 
		for(var x=0; x < play.length; x++)
		{		
			if(face_value == play[x]['card_value'])
			{			
				return true;
			}
		}
		for(var y =0; y < play_two.length; y++)
		{			
			if(face_value == play_two[y]['card_value'])
			{
				return true;
			}
		}
		return false;
	}		
		

	function Set_ErrorMessage(view)
	{
		clearTimeout(time);
		time = setTimeout(function()
		{
			view.fadeOut();
		}, 500);
			view.fadeIn(0);
	}

	function getfromThrowDeck_to_PlayerOne()
	{
		Collect_All_Cards(playerOneCard);
		
		for(var x = play.length - 1; x >= 0; x--)
		{
			playerOneCard.push(play.pop());
			$('.img_playOneDeck')[x].removeAttribute('src');
		}
		for(var y = play_two.length - 1; y >= 0; y--)
		{
			playerOneCard.push(play_two.pop());
			$('.img_playDeckTwo')[y].removeAttribute('src');
		}

		Rewrite_PlayerOneCard(playerOneCard);
	}

	function getfromThrowDeck_to_PlayerTwo()
	{
		for(var y = play_two.length - 1; y >= 0; y--)
		{
			playerTwoCard.push(play_two.pop());
			$('.img_playDeckTwo')[y].removeAttribute('src');
		}
		for(var x = play.length - 1; x >= 0; x--)
		{
			playerTwoCard.push(play.pop());
			$('.img_playOneDeck')[x].removeAttribute('src');
		}

		Collect_All_Cards(playerTwoCard);
		Rewrite_PlayerTwoCard(playerTwoCard);
	}

	function getFromCardDeck_to_PlayerOne()
	{			
		Collect_All_Cards(playerOneCard);
		for(var x = playerOneCard.length; x < 6; x++)
		{
			if(cardList.length <= 0)
			{

				if($('.trump').length > 0)
				{
				playerOneCard.push(trumpCard[0]);
				$('.trump')[0].remove();
				}
				break;
				
			}
			else
			{
				$('.imgDeck')[cardList.length - 1].remove();
				playerOneCard.push(cardList.pop());
			}
		}
		Rewrite_PlayerOneCard(playerOneCard);
	}

	function getFromCardDeck_to_PlayerTwo()
	{
		Collect_All_Cards(playerTwoCard);
		for(var y = playerTwoCard.length; y < 6; y++)
		{
			if(cardList.length <= 0)
			{
				if($('.trump').length > 0)
				{
				playerTwoCard.push(trumpCard[0]);
				$('.trump')[0].remove();
				}
				break;

			}
			else
			{
				$('.imgDeck')[cardList.length - 1].remove();
				playerTwoCard.push(cardList.pop());
			}
		}
		Rewrite_PlayerTwoCard(playerTwoCard);
	} 


	function AcceptCards()
	{	
		if(isPlayerOneAttacker)
		{
			
			if(!isEndAttack)
			{		

				$('#endAtck')[0].hidden = null;
				collectCards = true;
				$('#accptCards')[0].hidden = "hidden";
				$('#end')[0].innerHTML = "I accept, You may now add additional applicable cards to attack.";
				
			}
			else
			{
					isEndAttack = false;
					getfromThrowDeck_to_PlayerTwo();
					getFromCardDeck_to_PlayerOne();	

					$('#attck')[0].hidden = "hidden";	
					$('#accptCards')[0].hidden = "hidden";
					$('#end')[0].innerHTML = "";
			}			
		}
		else
		{
			
			if(!isEndAttack)
			{			
				$('#endAtck-p2')[0].hidden = null;
				collectCards = true;			
				 $('#accptCards-p2')[0].hidden = "hidden";			
				 $('#end-p2')[0].innerHTML = "I accept, You may now add additional applicable cards to attack.";
			}
			else
			{
				isEndAttack = false; 
				getfromThrowDeck_to_PlayerOne();
				getFromCardDeck_to_PlayerTwo();

				$('#attck-p2')[0].hidden = "hidden";	
				$('#accptCards-p2')[0].hidden = "hidden";
			 	$('#end-p2')[0].innerHTML = "";

			}	
		
		}	
	}

	function Collect_All_Cards(arrCards)
	{	
		for(var x = 0; x < arrCards.length; x++)
		{
			if(arrCards[x] == null)
			{
				arrCards.splice(x--, 1);
			}
		}
	}

	function clearDeck(playOne, playTwo)
	{
		var length = playOne.length;
		var length_pTwo = playTwo.length;

		for(var x = 0; x < length; x++)
		{
			$('.img_playOneDeck')[x].removeAttribute('src');	
			playOne.pop();
			
		}	
		for(var i = 0; i < length_pTwo; i++)
		{
			$('.img_playDeckTwo')[i].removeAttribute('src');
			playTwo.pop();
		}
	}


	function Rewrite_PlayerOneCard(arrPone)
	{
		$('#playerOneCardsContainer')[0].innerHTML = '';
		
		for(var x = 0; x < arrPone.length; x++)
		{
			$('#playerOneCardsContainer')[0].innerHTML += 
			'<img onclick=Set_PlayerOne('+ (x) +') class="img_playerOneCards" src="'+ img_base + arrPone[x]['card_image'] + '"/>' ; 
		}
		
	}

	function Rewrite_PlayerTwoCard(arrPtwo)
	{
		$('#playerTwoCardsContainer')[0].innerHTML = '';
		for(var y = 0; y < arrPtwo.length; y++)
		{
			$('#playerTwoCardsContainer')[0].innerHTML += 
			  '<img  onclick=Set_PlayerTwo('+ (y) +') class="img_playerTwoCards" src="'+ img_base + arrPtwo[y]['card_image'] + '"/>';
			  console.log( y + ''+ arrPtwo[y]['card_image']);
		}
	}
		
	function endAttackPlayerOne()
	{	
		
		if(collectCards)
		{
				getfromThrowDeck_to_PlayerTwo();
				getFromCardDeck_to_PlayerOne();
				$('#endAtck')[0].hidden = "hidden";			
				$('#end')[0].innerHTML = "";
		}
		else 
		{
			for(var x = 0; x < playerOneCard.length; x++)
			{
			$('.img_playerOneCards')[x].onclick = false;
			}
			for(var x = 0; x < playerTwoCard.length; x++)
			{
			 $('.img_playerTwoCards')[x].onclick = false;
			}
			$('#endAtck')[0].hidden = "hidden";
			$('#end')[0].innerHTML = "I end my attack. Choose to accept cards or to attack.";
			$('#attck')[0].hidden = null;
			$('#accptCards')[0].hidden = null;
			isEndAttack = true
		}

		
		collectCards = false;
		
			
	}
	function endAttackPlayerTwo()
	{	

		if(collectCards)
		{
			getfromThrowDeck_to_PlayerOne();
			getFromCardDeck_to_PlayerTwo();
			$('#end-p2')[0].innerHTML = "";
			$('#endAtck-p2')[0].hidden = "hidden";
		}
		else
		{
			for(var x = 0; x < playerOneCard.length; x++)
			{
				$('.img_playerOneCards')[x].onclick = false;
			}
			for(var x = 0; x < playerTwoCard.length; x++)
			{
				 $('.img_playerTwoCards')[x].onclick = false;
			}
			 $('#endAtck-p2')[0].hidden = "hidden";
			 $('#end-p2')[0].innerHTML = "I end my attack. Choose to accept cards or to attack.";
			 $('#attck-p2')[0].hidden = null;	
			 $('#accptCards-p2')[0].hidden = null;

			isEndAttack = true;
		}

		collectCards = false;		
	}

	function attackPlayerOne()
	{

		isEndAttack = false;
		
		Generate_All_Cards(false);
		
		Collect_All_Cards(playerOneCard);
		Collect_All_Cards(playerTwoCard);
		
		Rewrite_PlayerOneCard(playerOneCard);
		Rewrite_PlayerTwoCard(playerTwoCard);		

		clearDeck(play, play_two);

		getFromCardDeck_to_PlayerOne();
		getFromCardDeck_to_PlayerTwo();

		$('#attck')[0].hidden = "hidden";
		$('#accptCards')[0].hidden = "hidden";	
		$('#end')[0].innerHTML = "";
	}

	function attackPlayerTwo()
	{
		console.log('attack sa player one');
		isEndAttack = false;
		Generate_All_Cards(true);
		console.log('attack sa player one');

		Collect_All_Cards(playerOneCard);
		Collect_All_Cards(playerTwoCard);
		console.log('attack sa player one');

		Rewrite_PlayerOneCard(playerOneCard);
		Rewrite_PlayerTwoCard(playerTwoCard);
		console.log('attack sa player one');

		clearDeck(play, play_two);
		
		getFromCardDeck_to_PlayerTwo();
		getFromCardDeck_to_PlayerOne();
			

		
		$('#attck-p2')[0].hidden = "hidden";
		$('#accptCards-p2')[0].hidden = "hidden";		
		$('#end-p2')[0].innerHTML = "";
	}


	function loadFn()
	{	

		$('#endAtck-p2')[0].hidden = "hidden";
		$('#accptCards')[0].hidden = "hidden";		
		$('#attck')[0].hidden = "hidden";

		$('#endAtck')[0].hidden = "hidden";	
		$('#accptCards-p2')[0].hidden = "hidden";
		$('#attck-p2')[0].hidden = "hidden";
	
	}

</script>


	<div id="mLink">
		<p class="link">
				<?php
				echo anchor('durak','Login');
				echo nbs(1)."|".nbs(1);
				echo anchor('durak/register','Register');
				?>
		</p>
	</div>

		<div id="body">
				
				<p class="name">Welcome!</p>
				<p id="sub">Guest (Turn by turn game)</p>
			  	<p id="wins"></p>
				

			<div id="option">
				<p>Choose Attacker:</p>
					<button class="btn" onClick="Generate_All_Cards(true)">Player One</button><br/><br/>
					<button class="btn" onClick="Generate_All_Cards(false)">Player Two</button>
			</div>

		
			<table id="whole-deck">

				<tr id="playerOneCardsonHand">
			
					<td colspan="2">

								<p id="ptitle"></p>
								<p id="atitle"></p>

								<div id="statBtn">
										<div id="endAtck">
											<button onclick=endAttackPlayerOne() id="btn1">End Attack</button>
										</div>
										<div id="accptCards-p2">
											<button onClick=AcceptCards() id="btn1">Accept Cards</button>
										</div>
										<div id="attck-p2">
											<button onclick=attackPlayerTwo() id="btn1">Attack</button>
										</div>
								</div>

							<div id="playerOneCardsContainer">
							</div>

						<p id="note1"></p>						
						<p id="turn"></p>
						<p id="end-p2"></p>
					</td>

				</tr>


				<tr id="row-mid-deck">

					<td id="col-mid-deck">
							<div id="deckContainer"></div> 
							<div id="trumpContainer"></div>
								<p id="trumpTitle"></p>
					</td>

					<td id="col-mid-throwDeck">						
							<?php 
								echo '<div id="player-One-ThrowDeck">';
									for($x = 0; $x < 6; $x++)
									{	
										
										echo '<img class="img_playOneDeck"/>';
									} 	
								echo '</div>';
								echo '<div id=playerTwoDeckContainer>';
									for($x = 0; $x < 6; $x++)
									{	
										
										echo '<img class="img_playDeckTwo"/>';
									}
								echo '</div>'; 	
							?>
					</td>
				</tr>


				<tr>
					
					<td colspan="2">
						<div id="status2"> 
						<p id="ptitle1"></p>
						<p id="atitle1"></p>

							<div id="endAtck-p2">
								<button onclick=endAttackPlayerTwo() id="btn1">End Attack</button>
							</div>

							<div id="accptCards">
								<button onClick=AcceptCards() id="btn1">Accept Cards</button>
							</div>

							<div id="attck">
								<button onclick=attackPlayerOne() id="btn1">Attack</button>
							</div>
						</div>

								<div id="playerTwoCardsContainer">
								</div>

						<p id="note"></p>
						<p id="end"></p>
					
					</td>
				</tr>		
			</table>
		</div>



	<p class="footer">
		Page rendered in 
			<strong>{elapsed_time}</strong>
		seconds
	</p>
